package com.wfm.leetcode.editor.cn;

import com.wfm.common.TreeNode;

public class PSix17合并二叉树{
//leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public TreeNode mergeTrees(TreeNode root1, TreeNode root2) {
        if(root1==null) return root2;
        if(root2==null) return root1;
        TreeNode newT = new TreeNode(root1.val+root2.val);
        newT.left = mergeTrees(root1.left,root2.left);
        newT.right = mergeTrees(root1.right,root2.right);
        return newT;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

    public static void main(String[] args) { 
        Solution solution = new PSix17合并二叉树().new Solution();
    }
}